package cn.stylefeng.guns.generator.engine.config;

import cn.stylefeng.guns.generator.executor.config.GunsGeneratorConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 控制器模板生成的配置
 *
 * @author fengshuonan
 * @date 2017-05-07 22:12
 */
@Data
public class ControllerConfig {

    private String controllerPathTemplate;
    private List<String> imports;//所引入的包

    public ControllerConfig(GunsGeneratorConfig gunsGeneratorConfig) {
        ArrayList<String> imports = new ArrayList<>();
        imports.add("org.apache.shiro.authz.annotation.RequiresPermissions");
        imports.add("org.springframework.stereotype.Controller");
        imports.add("org.springframework.web.bind.annotation.RequestMapping");
        imports.add("org.springframework.web.bind.annotation.ResponseBody");
        imports.add("org.springframework.ui.Model");
        imports.add("org.springframework.web.bind.annotation.PathVariable");
        imports.add("org.springframework.beans.factory.annotation.Autowired");
        imports.add("cn.stylefeng.guns.core.log.LogObjectHolder");
        imports.add("cn.stylefeng.guns.core.common.annotion.Permission");
        imports.add("org.springframework.web.bind.annotation.RequestParam");
        imports.add("cn.stylefeng.roses.core.base.controller.BaseController");
        imports.add("cn.stylefeng.roses.core.reqres.response.ResponseData");
        imports.add("cn.stylefeng.guns.core.common.page.LayuiPageInfo");
        ContextConfig contextConfig = gunsGeneratorConfig.getContextConfig();
        imports.add(gunsGeneratorConfig.getPackageConfig().getEntity()+ "." + contextConfig.getEntityName());
        imports.add(contextConfig.getModelPackageName() + ".service" + "." + contextConfig.getEntityName() + "Service");
        imports.add(ReqParamConfig.getPackName(contextConfig.getModelPackageName(),contextConfig.getEntityName()));
        this.imports = imports;
        this.controllerPathTemplate = JavaPathUtils.getControllerPath(contextConfig.getProPackage(),contextConfig.getModuleName());
    }

}
